<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>日志管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="/webuploader/webuploader.css">

    <script src="/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/webuploader/webuploader.js"></script>
    <script src="/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
        layui.config({
            base : "/layui/js/"
        }).use(['form', 'layedit', 'laydate','table','common'], function(){
            var form = layui.form ,laydate = layui.laydate ,table = layui.table ,layer = layui.layer,layedit = layui.layedit,common = layui.common,$ = layui.$;
            laydate.render({
                elem: '#projectCreateYear'
                ,type: 'year'
            });
            laydate.render({
                elem: '#yearMonthDay'

            });
            laydate.render({
                elem: '#year'

            });
            /* form.render();//更新渲染表单*/
            //分页查询

            layui.use('table', function(){
                var table = layui.table;

                table.render({
                    elem: '#TableId',
                    id:'TableId',
                    even: true,
                    url: '/log/findLogWithPage', //数据接口
                    limit:10,
                    limits:[10,20,30,50,100],
                    page: true ,//开启分页
                    cols: [[ //表头
                        {
                            field : 'logId',
                            title : 'Id',
                            type:   'checkbox'

                        },{
                            field : 'userName',
                            title : '操作用户'
                        },{
                            field : 'operation',
                            title : '具体操作'
                        },{
                            field : 'createDate',
                            title : '操作时间'
                        },{
                            field : 'ip',
                            title : 'IP地址'
                        }]]
                });

                /**查询*/
                $(".search_btn").click(function(){
                    var loading = layer.load(0,{ shade: [0.3,'#000']});
                    //监听提交

                    debugger;
                    table.reload('TableId',{
                        where: {
                            userName:$('#searchName').val(),
                            operation:$('#searchDo').val()
                        },
                        page: true,
                        done: function (res, curr, count) {
                            common.resizeGrid();
                            layer.close(loading);

                        }
                    });
                });

            });


            /**批量删除*/

            var $ = layui.$, active = {
                delCheckData: function () { //获取选中数据
                    var checkStatus = table.checkStatus('TableId')
                            , data = checkStatus.data;

                    if (data.length == 0) {
                        layer.msg('请选择要删除的数据！', {
                            time: 1000,
                        });
                        return;
                    } else {
                        var delList = [];
                        for (var i in data) {
                            delList.push(data[i].projectCreateId);
                        }
                        debugger;
                        layer.confirm('你确定要删除吗？', {
                            btn: ['确定', '返回'] //按钮
                        }, function () {
                            $.post("/project/delManyProjectInfo", {"pIds[]": delList}, function (flag) {
                                if (flag==true) {
                                    layer.msg('删除成功！', {
                                        time: 500,
                                    });
                                    table.reload("TableId")
                                }else if(flag==false){
                                    layer.msg('删除失败，该项目在计划年度或项目年度中存在，无法删除！！', {
                                        time: 5000,
                                    });
                                }
                            })
                        }, function () {
                            layer.msg('关闭', {
                                time: 1000, //1秒后自动关闭
                            });
                        });
                    }


                }
            };

            $('.demoTable .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });

        })

    </script>

</head>
<body>
<#--条件查询模块-->
<form class="layui-form layui-form-pane"  method="post" lay-filter="SearchFilter"  >


    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">操作用户</label>
            <div class="layui-input-inline">
                <input type="text" id="searchName" name="userName"  class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">操作</label>
            <div class="layui-input-inline">
                <input type="text" id="searchDo" name="operation"  class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <a class="layui-btn search_btn" lay-submit id="search_btn" lay-submit="" lay-filter="search">查询</a>
        </div>

    </div>
</form>
<input type="hidden" value="${loginName}" id="loginName">
<#--<div class="layui-btn-group demoTable" style="margin-bottom: -10px;">-->
    <#--<shiro:hasAnyRoles name="SUPERADMIN">-->
        <#--<button class="layui-btn" data-type="delCheckData">批量删除</button>-->
    <#--</shiro:hasAnyRoles>-->

<#--</div>-->

<table class="layui-table-cell" id="TableId" lay-filter="TableId" lay-data="{id: 'TableId'} skin: 'row'" ></table>

<div style="margin-bottom: 250px"></div>
</body>
</html>
